<?php
namespace app\admin\controller;

use app\common\lib\Status as StatusLib;
use think\facade\View;

class SpecsValue extends AdminBase {
    public function getBySpecsId(){
        $specsId = input('param.specs_id',0,'intval');
        if (!$specsId){
            return show('status.success','没有数据');
        }
        $result = (new \app\common\business\SpecsValue())->getBySpecsId($specsId);
        return show(config('status.success'),'OK', $result);
    }

    public function save(){
        $specsId = input('param.specs_id',0,'intval');
        $name = input('param.name','','trim');
        $data = [
            'specs_id'=>$specsId,
            'name'=>$name,
        ];
        $id = (new \app\common\business\SpecsValue())->add($data);
        if(empty($id)){
            return show(config('status.error'),'新增失败');
        }
        return show(config('status.success'),'OK', ['id'=>$id]);
    }
}